package me.zk.practice1.s;

import java.util.Arrays;

/**
 * @Author: zhang kai
 * @Date: 2023/04/27
 * @Description:
 */
public class S2 {
    public static void main(String[] args) {
        int[] array = {1,2,3,4,5,6,7,8,9};

        System.out.println(sum(array));
    }

    public static int sum(int[] array) {
        if (array == null ||array.length == 0){
            return 0;
        }

        return array[array.length-1] + sum(Arrays.copyOf(array,array.length-1));
    }
}
